package com.softme.trade.model.dao;

import java.io.Serializable;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.softme.trade.model.Role;

public class RoleDAO extends HibernateDaoSupport implements Serializable
{
	public Role findByName(String value)
	{
		String query = "from Role where name = :value";

		List<Role> result = this.getHibernateTemplate().findByNamedParam(query, "value", value);
		
		if (result != null && result.size() > 0)
			return result.get(0);
		
		return null;
	}

	public List<Role> loadAll()
	{
		return getHibernateTemplate().loadAll(Role.class);
	}

	public Role load(Long id)
	{
		return getHibernateTemplate().get(Role.class, id);
	}

	public void saveOrUpdate(Role role)
	{
		getHibernateTemplate().saveOrUpdate(role);
	}

	public void save(Role role)
	{
		getHibernateTemplate().save(role);
	}

	public void delete(Role role)
	{
		getHibernateTemplate().delete(role);
	}
}
